<script>
export default {
  name: 'StyleBadge',
  functional: true,
  props: {
    qstyle: {
      type: Number,
      required: true,
      validator(value) {
        return [0, 1].indexOf(value) >= 0
      }
    }
  },
  render(h, context) {
    const textMap = {
      0: '选择题',
      1: '填空题'
    }
    const colorMap = {
      0: 'orange400',
      1: 'purple400'
    }
    const qstyle = context.props.qstyle
    const content = textMap[qstyle] || '未知形式'
    const color = colorMap[qstyle] || 'grey400'
    return h('mu-badge', { props: { content, color } })
  }
}
</script>
